﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bluyel.Core
{
    public class ValueLong : ValueBase, IValueBasic
    {
        /// <summary>
        /// The data value.
        /// </summary>
        private long _value;

        //---------------------------------------------------------------------
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="value"></param>
        public ValueLong()
        {
            //this.DataValueType = DataValueType.Double;

            // init to empty (not to null)
            _value = 0;
        }

        //---------------------------------------------------------------------
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="value"></param>
        public ValueLong(long value)
        {
            _value = value;
        }

        //---------------------------------------------------------------------
        /// <summary>
        /// Set a new value. 
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public bool SetValue(long val)
        {
            // can be null?
            // todo:

            _value = val;
            return true;
        }

        //---------------------------------------------------------------------
        /// <summary>
        /// Return the value.
        /// </summary>
        /// <returns></returns>
        public long GetValue()
        {
            return _value;
        }

        //---------------------------------------------------------------------
        /// <summary>
        /// Compare: this == dv
        /// return true/false.
        /// </summary>
        /// <param name="dv"></param>
        /// <returns></returns>
        public override bool IsEqualsTo(IValue dv)
        {
            ValueLong dvLong = dv as ValueLong;
            if (dvLong == null)
                return false;

            return this.GetValue() == dvLong.GetValue();
        }

        //---------------------------------------------------------------------
        public override string ToString()
        {
            return _value.ToString();
        }
    }
}
